<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/7/1
 * Time: 10:16
 */
namespace Admin\Model;


use Base\Model\BaseModel;
use Think\Page;

class DoseinfoModel extends BaseModel
{
    protected $_validate = array(
        array('value', 'require', '剂量规格必须填写'),
//        array('value','/^[0-9]+$/', '越界了，剂量大小只能输入整数型！',3),
        array('dosenameID', 'require', '剂量名称必须选择'),
//        array('contentID', 'require', '剂量单位必须选择'),
		//array('value','checkIdCard', '剂量大小只能为整数或者浮点数',2),
    );
	protected function checkIdCard($idcard){  
        if(empty($idcard)){  
            return false;  
        }  
            if(!preg_match('/^\d{17}(\d|x)$/i',$idcard) and !preg_match('/^\d{15}$/i',$idcard))
        {  
            return false;  
        }  
    }
    protected $_link=array(
        'dosename' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'    => 'dimdailyiteminfo',
            'foreign_key' => 'dosenameid',
            'parent_key' => 'id',
          'mapping_fields' => 'id,name'
        ),
        'content' => array(
            'mapping_type' => self::BELONGS_TO,
            'class_name'    => 'dimdailyiteminfo',
            'foreign_key' => 'contentid',
            'parent_key' => 'id',
            'mapping_fields' => 'id,name'
        ),
    );
    protected $_auto = array(
        array('status', '1'),
    );
}